package com.jic.manager.impl;

import java.lang.Long;
import java.util.List;

import com.jic.common.base.vo.Page;
import com.jic.manager.entity.StoreRating;
import com.jic.manager.mapper.StoreRatingMapper;
import com.jic.manager.request.StoreRatingRequest;
import com.jic.manager.response.StoreRatingResponse;
import com.jic.manager.service.StoreRatingService;
import com.jic.common.base.vo.PageResult;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 店铺评分表
 * @author : 
 * @email : 
 * @since : 2020-03-02 08:37:09
 * @version : v1.0.0
 */
@Service
public class StoreRatingServiceImpl implements StoreRatingService{

    @Autowired
    private StoreRatingMapper storeRatingMapper;

    @Override
    public long insert(StoreRating storeRating) {
        long flag = storeRatingMapper.insert(storeRating);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return storeRatingMapper.delete(id);
    }

    @Override
    public long update(StoreRating storeRating) {
        return storeRatingMapper.update(storeRating);
    }

    @Override
    public StoreRating queryByPrimaryKey(Long id){
        return storeRatingMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<StoreRating> query(StoreRating storeRating){
        return storeRatingMapper.query(storeRating);
    }

    @Override
    public PageResult<StoreRatingResponse> queryPage(StoreRatingRequest storeRating, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<StoreRatingRequest> list = storeRatingMapper.queryPage(startIndex, pageQuery.getLimit(), storeRating);
        long count = storeRatingMapper.queryPageCount(storeRating);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }

    @Override
    public PageResult<StoreRatingResponse> getStoreCommentList(StoreRatingRequest storeRating, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<StoreRatingRequest> list = storeRatingMapper.getStoreCommentList(startIndex, pageQuery.getLimit(), storeRating);
        long count = storeRatingMapper.queryCommentCount(storeRating);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }


}